(defun primep (x)
  (cond ((< x 4) T)
	((zerop (mod x 2)) nil)
	( t
	 (let ((sqrt-x (sqrt x)))
	   (do ((i 3 (+ i 2)))
	       ((> i sqrt-x) t)
	     (when (zerop (mod x  i)) 
	       (return nil)))))))

(defun nth-prime (n)
  (do ((i 2 (1+ i))
       (j 1 (if (primep i) (1+ j) j)))
      ((> j n) (- i 1))))

(print (nth-prime 10001))